I'm learning React.js recently,
and I have some questions,
As we know setState is asynchrony, if we don't use js framework, we will use let const or var to setting variable, it's synchrony, but why we should much more use state instead of let const var to setting variable in React.js?
Some scenario I use state but it cannot work very well to my WebApp, so that I try to use let to set my variable, and it can work very well, but I think if I use let rather than state, is it not a good idea because I wasted React.js advantage?
thank you for your help :>
Simply, in most cases we use state if we will use it in the UI ( in the JSX mockups ), as when it updates with setState the UI updates, this doesn't happen with normal javascript variables as it re-initializes when the component updates.
That's besides that other hooks, just updates regard to stateful dependencies only, like useEffect, useMemo, useCallback.